<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>原理 | siphan</title>
    <meta name="description" content="一个简单易用的 JavaScript 前端加密库">
    <meta name="generator" content="VuePress 1.3.0">
    
    
    <link rel="preload" href="/siphan/assets/css/0.styles.bab5f12a.css" as="style"><link rel="preload" href="/siphan/assets/js/app.a096c374.js" as="script"><link rel="preload" href="/siphan/assets/js/2.b96ecc85.js" as="script"><link rel="preload" href="/siphan/assets/js/10.e5803348.js" as="script"><link rel="prefetch" href="/siphan/assets/js/11.1506d706.js"><link rel="prefetch" href="/siphan/assets/js/12.9fea4da3.js"><link rel="prefetch" href="/siphan/assets/js/3.c42c2ebd.js"><link rel="prefetch" href="/siphan/assets/js/4.5f9aa696.js"><link rel="prefetch" href="/siphan/assets/js/5.537dfae2.js"><link rel="prefetch" href="/siphan/assets/js/6.c506cd42.js"><link rel="prefetch" href="/siphan/assets/js/7.0de11c07.js"><link rel="prefetch" href="/siphan/assets/js/8.83590e60.js"><link rel="prefetch" href="/siphan/assets/js/9.b0b386d5.js">
    <link rel="stylesheet" href="/siphan/assets/css/0.styles.bab5f12a.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/siphan/" class="home-link router-link-active"><img src="https://s2.ax1x.com/2020/02/26/3aERFe.png" alt="siphan" class="logo"> <span class="site-name can-hide">siphan</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/siphan/" class="nav-link">
  主页
</a></div><div class="nav-item"><a href="/siphan/guide/" class="nav-link router-link-active">
  入门
</a></div><div class="nav-item"><a href="/siphan/API/" class="nav-link">
  API
</a></div><div class="nav-item"><a href="http://service.shawroger.com/siphan" target="_blank" rel="noopener noreferrer" class="nav-link external">
  示例
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div><div class="nav-item"><a href="https://gitee.com/shawroger/siphan" target="_blank" rel="noopener noreferrer" class="nav-link external">
  仓库
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/siphan/" class="nav-link">
  主页
</a></div><div class="nav-item"><a href="/siphan/guide/" class="nav-link router-link-active">
  入门
</a></div><div class="nav-item"><a href="/siphan/API/" class="nav-link">
  API
</a></div><div class="nav-item"><a href="http://service.shawroger.com/siphan" target="_blank" rel="noopener noreferrer" class="nav-link external">
  示例
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div><div class="nav-item"><a href="https://gitee.com/shawroger/siphan" target="_blank" rel="noopener noreferrer" class="nav-link external">
  仓库
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div> <!----></nav>  <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>入门</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/siphan/guide/" class="sidebar-link">简介</a></li><li><a href="/siphan/guide/start.html" class="sidebar-link">快速开始</a></li><li><a href="/siphan/guide/principle.html" class="active sidebar-link">原理</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/siphan/guide/principle.html#基本思路" class="sidebar-link">基本思路</a></li><li class="sidebar-sub-header"><a href="/siphan/guide/principle.html#安全性论证" class="sidebar-link">安全性论证</a></li><li class="sidebar-sub-header"><a href="/siphan/guide/principle.html#关于合法密钥" class="sidebar-link">关于合法密钥</a></li></ul></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="原理"><a href="#原理" class="header-anchor">#</a> 原理</h1> <h2 id="基本思路"><a href="#基本思路" class="header-anchor">#</a> 基本思路</h2> <p><strong>Siphan</strong> 的出发点是加密中最基本的凯撒加密法，即生成内置字典的一个随机排序进行比对替换加密。</p> <p>为了更提升安全性，<strong>Siphan</strong> 还针对字符不同淡定位置再次进行偏移，如果是 <strong>UTF8</strong> 字符，还将进行解码编码运算，最后生成一个乱序的字典表和一个密文。</p> <p><img src="https://s2.ax1x.com/2020/02/26/3NXRbt.jpg" alt="原理图"></p> <h2 id="安全性论证"><a href="#安全性论证" class="header-anchor">#</a> 安全性论证</h2> <p><strong>Siphan</strong> 内置了 <strong>84</strong> 个字符，安装原理加密，可以生成的密钥共有 <strong>84!</strong> 种类，这是一个 <strong>127</strong> 位数，而且在采用了 <strong>UTF8</strong> 编码之后，密钥不正确将无法被解码，更保证了安全性。</p> <h2 id="关于合法密钥"><a href="#关于合法密钥" class="header-anchor">#</a> 关于合法密钥</h2> <p>为了允许使用自定义的字典，在当前版本 <strong>Siphan</strong> 提供了一个检测密钥合法性的方法 <a href="/siphan/API/#checkkey">checkKey</a>，而且还可以使用 <a href="/siphan/API/#createkey">createKey</a> 方法生成一个在当前字典内绝对合法的密钥，建议永远不要尝试手动生成密钥，这将会是一个繁杂的工作。</p></div> <footer class="page-edit"><!----> <!----></footer> <div class="page-nav"><p class="inner"><span class="prev">
      ←
      <a href="/siphan/guide/start.html" class="prev">
        快速开始
      </a></span> <!----></p></div> </main></div><div class="global-ui"></div></div>
    <script src="/siphan/assets/js/app.a096c374.js" defer></script><script src="/siphan/assets/js/2.b96ecc85.js" defer></script><script src="/siphan/assets/js/10.e5803348.js" defer></script>
  </body>
</html>
